//    Openbravo POS is a point of sales application designed for touch screens.
//    Copyright (C) 2007-2009 Openbravo, S.L.
//    http://www.openbravo.com/product/pos
//
//    This file is part of Openbravo POS.
//
//    Openbravo POS is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Openbravo POS is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.

report = new com.openbravo.pos.reports.PanelReportBean();

report.setTitleKey("Menu.TaxCatSales");
report.setReport("/com/openbravo/reports/taxcatsales");
report.setResourceBundle("com/openbravo/reports/taxcatsales_messages");

report.setSentence(
	"SELECT " +
		"CLOSEDCASH.HOST, " +
		"CLOSEDCASH.MONEY, " +
		"CLOSEDCASH.DATEEND, " +
		"TAXES.NAME AS TAXNAME, CATEGORIES.NAME, " +
		"SUM(TICKETLINES.UNITS) AS QTY, " +
		"SUM(TICKETLINES.PRICE * TICKETLINES.UNITS) AS CATPRICE, " +
		"SUM((TICKETLINES.PRICE * TAXES.RATE ) * TICKETLINES.UNITS) AS CATTAX, "+
		"SUM((TICKETLINES.PRICE + TICKETLINES.PRICE * TAXES.RATE ) * TICKETLINES.UNITS) " +
		"AS CATTOTAL " +
		"FROM CLOSEDCASH, TAXES, TICKETLINES " +
		"LEFT OUTER JOIN PRODUCTS ON TICKETLINES.PRODUCT = PRODUCTS.ID " +
		"LEFT OUTER JOIN PRODUCTS_CAT ON PRODUCTS_CAT.PRODUCT = PRODUCTS.ID " +
		"LEFT OUTER JOIN CATEGORIES ON PRODUCTS.CATEGORY = CATEGORIES.ID " +
		"LEFT OUTER JOIN TICKETS ON TICKETS.ID = TICKETLINES.TICKET " +
		"LEFT OUTER JOIN RECEIPTS ON RECEIPTS.ID = TICKETS.ID " +
		"WHERE CLOSEDCASH.MONEY = RECEIPTS.MONEY "+
		"AND TICKETLINES.TAXID = TAXES.ID " +
		"AND ?(QBF_FILTER) " +
		"GROUP BY TAXES.NAME, CATEGORIES.NAME " +
		"ORDER BY TAXES.NAME, CATEGORIES.NAME");

report.addParameter("CLOSEDCASH.DATEEND");
report.addParameter("CLOSEDCASH.DATEEND");
report.addQBFFilter(new com.openbravo.pos.reports.JParamsDatesInterval());

report.addField("HOST", com.openbravo.data.loader.Datas.STRING);
report.addField("MONEY", com.openbravo.data.loader.Datas.STRING);
report.addField("DATEEND", com.openbravo.data.loader.Datas.TIMESTAMP);
report.addField("TAXNAME", com.openbravo.data.loader.Datas.STRING);
report.addField("NAME", com.openbravo.data.loader.Datas.STRING);
report.addField("QTY", com.openbravo.data.loader.Datas.STRING);
report.addField("CATPRICE", com.openbravo.data.loader.Datas.DOUBLE);
report.addField("CATTAX", com.openbravo.data.loader.Datas.DOUBLE);
report.addField("CATTOTAL", com.openbravo.data.loader.Datas.DOUBLE);

report;